Strict

Import mojo.app
Import mojo.graphics
Import ball
Import diddy
Import bonusBallBounceScreen

Class BonusSequenceScreen extends BonusBallBounceScreen
	Const EVENS:Int = 0
	Const MAX_TIME:Int = 60 'seconds
	Field regenerationCounter:Int = 0
	Field roundBallCount:Int=0
	Field roundBallVelocity:Float=0
	Field roundBallSize:Float=0
	Field numberRangeMin:Int = 1
	Field numberRangeMax:Int = 100

	
	Field time:Int

	Method New()
		super.New()
		name="BonusSequenceScreen"
		bgImage = game.images.Find("bonusBounceBG")
	End	
	
	Method SetDifficulty:void(time:Int, startBallCount:Int, startballVelocity:Float, pointsToMax:Int)
		self.time = time
		self.roundBallCount = startBallCount
		self.roundBallVelocity = startballVelocity
		self.pointsToMax = pointsToMax
		self.regenerationCounter = 0
	End
	
	Method Start:Void()	
		if(_model.currentDifficulty=Model.DIFFICULTY_EASY)
			self.time = 60
			self.roundBallCount = 5
			self.roundBallVelocity = 1
			self.pointsToMax = 12
			self.regenerationCounter = 0	
			self.roundBallSize=50	
			Self.numberRangeMin=1
			Self.numberRangeMax=20
			Print "DIFFICULTY_EASY"
		ElseIf(_model.currentDifficulty=Model.DIFFICULTY_MEDIUM)
			self.time = 60
			self.roundBallCount = 7
			self.roundBallVelocity = 1.5
			self.pointsToMax = 21
			self.regenerationCounter = 0
			self.roundBallSize=40	
			Self.numberRangeMin=1
			Self.numberRangeMax=100
				Print "DIFFICULTY_MEDIUM"
		ElseIf(_model.currentDifficulty=Model.DIFFICULTY_HARD)
			self.time = 60
			self.roundBallCount = 9
			self.roundBallVelocity = 2
			self.pointsToMax = 33
			self.regenerationCounter = 0
			self.roundBallSize=30	
			Self.numberRangeMin=-100
			Self.numberRangeMax=100
				Print "DIFFICULTY_HARD"
		ElseIf(_model.currentDifficulty=Model.DIFFICULTY_GENIUS)
			self.time = 60
			self.roundBallCount = 11
			self.roundBallVelocity = 2.5
			self.pointsToMax = 42
			self.regenerationCounter = 0
			self.roundBallSize=30	
			Self.numberRangeMin=-100
			Self.numberRangeMax=100
				Print "DIFFICULTY_GENIUS"				
		EndIf
 		Super.Start()
   End   
	
	Method doMouseHit:void(ball:Ball)
		Local isRight:Bool = false
		Local lowestNumber:Int = 9999
		
		'Get lowest number
		For Local ndx:Int=0 Until GetMaxBalls()
			Local tempBall:Ball  = ballsList.Get(ndx)
			if(tempBall.alive)
				lowestNumber = Min(lowestNumber, tempBall.number)
			End
		Next
		
		if(lowestNumber = ball.number)
			scoreStatusBar.AddPoints()			
			isRight=true
			
		else
			scoreStatusBar.SubtractPoints()
			isRight=false
		End
		
		regenerationCounter-=1

		ball.Kill()
		DoWrongRight(ball.position.x, ball.position.y, isRight)
	End
	

	Method GetMaxBalls:Int()
		return roundBallCount
	End
	

	Method GetNextGeneration:void()	
		regenerationCounter=0
		For Local ndx:Int=0 Until GetMaxBalls()
			Local radius:Float = roundBallSize+Rnd(30)
			Local tempBall:Ball = new Ball(Rnd(SCREEN_WIDTH), Rnd(SCREEN_HEIGHT), radius, 0.1)
			
			tempBall.velocity.set(roundBallVelocity-Rnd(roundBallVelocity*2), roundBallVelocity-Rnd(roundBallVelocity*2))
			tempBall.number=Rnd(numberRangeMin, numberRangeMax)
			
			regenerationCounter+=1

		   	ballsList.Add(tempBall)
		next		
	End
	
	Method SetRoundAttributes:void()
		roundBallCount = roundNumber+3
		roundBallVelocity+=0.10
	End	
		
	Method GetRegenerationCounter:Int()
		return regenerationCounter
	End
	
	Method GetMaxTimer:Int()
		return time
	End
	
	Method GetInstructions:String()
		return "BASH THE GUYS, LOWEST FIRST"
	End
End